<?php
	<?php
try
{
	$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;	
	$bdd = new PDO('mysql:host=localhost;dbname=mainbdd', 'root', '', $pdo_options);
	
class Player
{
	private $id;
	
	private $pseudo;
	private $mail;
	private $mdp;
	private $registerdate;
	private $gold;
	private $xp;
	private $lvl;
	
	private $total;
	private $noAction;
	private $working;
	private $fighting;
	private $training;
	private $munitions;
	private $recherche;
	private $lvl1;
	private $lvl2;
	private $lvl3;
	private $lvl4;
	private $lvl5;
	
	public function __construct($idMembre)
	{
		$bdd = new PDO('mysql:host=localhost;dbname=mainbdd', 'root', '');
		$req_units = $bdd->prepare('SELECT * FROM units WHERE ID = ?');
		$req_units->execute(array($idMembre));
		$req_units_fetch = $req_accounts->fetch();
		$req_units->closeCursor();
		
		$this->id = $idMembre;
		$this->noAction = $req_units_fetch['NOACTION'];
		$this->working = $req_units_fetch['WORKING'];
		$this->fighting = $req_units_fetch['FIGHTING'];
		$this->training = $req_units_fetch['TRAINING'];
		$this->munitions = $req_units_fetch['MUNITIONS'];
		$this->recherche = $req_units_fetch['RECHERCHE'];
		$this->lvl1 = $req_units_fetch['LVL1'];
		$this->lvl2 = $req_units_fetch['LVL2'];
		$this->lvl3 = $req_units_fetch['LVL3'];
		$this->lvl4 = $req_units_fetch['LVL4'];
		$this->lvl5 = $req_units_fetch['LVL5'];		
		$this->total = $req_units_fetch['NOACTION'] + $req_units_fetch['WORKING'] + $req_units_fetch['FIGHTING'] + $req_units_fetch['TRAINING'] + $req_units_fetch['MUNITIONS'] + $req_units_fetch['RECHERCHE'];
		
	}//__construct
	
	public function getID(){return $this->id;}
	public function getnoAction(){return $this->noAction;}
	public function getWorking(){return $this->working;}
	public function getFighting(){return $this->fighting;}
	public function getTraining(){return $this->training;}
	public function getMunitions(){return $this->munitions;}
	public function getRecherche(){return $this->recherche;}
	public function getTotal(){return $this->total;}
	public function getLvl1(){return $this->lvl1;}
	public function getLvl2(){return $this->lvl2;}
	public function getLvl3(){return $this->lvl3;}
	public function getLvl4(){return $this->lvl4;}
	public function getLvl5(){return $this->lvl5;}
	
	public function setID($newID){$this->id = $newID;}
	public function setNoAction($newNoAction){$this->noAction = $newNoAction;}
	public function setWorking($newWorking){$this->working = $newWorking;}
	public function setFighting($newFighting){$this->fighting = $newFighting;}
	public function setTraining($newTraining){$this->training = $newTraining;}
	public function setMunitions($newMunition){$this->munitions = $newMunitions;}
	public function setTotal($newTotal){$this->total = $newTotal;}
	public function setRecherche($newRecherche){$this->noRecherche = $newRecherche;}
	public function setLvl1($newLvl1){$this->lvl1 = $newLvl1;}
	public function setLvl2($newLvl2){$this->lvl2 = $newLvl2;}
	public function setLvl3($newLvl3){$this->lvl3 = $newLvl3;}
	public function setLvl4($newLvl4){$this->lvl4 = $newLvl4;}
	public function setLvl5($newLvl5){$this->lvl5 = $newLvl5;}
	
	public function updateBDD()
	{
		$bddc = new PDO('mysql:host=localhost;dbname=mainbdd', 'root', '');
		
		$req_units_in = $bddc->prepare('UPDATE accounts set ID = :ID, NOACTION = :NOACTION, WORKING = :WORKING, FIGHTING = :FIGHTING, TRAINING = :TRAINING, MUNITIONS = :MUNITIONS, RECHERCHE = :RECHERCHE, LVL1 = :LVL1, LVL2 = :LVL2, LVL3 = :LVL3, LVL4 = :LVL4, LVL5 = :LVL5');
		$req_units_in->execute(array(
			'ID' => $this->id,
			'NOACTION' => $this->noAction,
			'WORKING' => $this->working,
			'FIGHTING' => $this->fighting,
			'TRAINING' => $this->training,
			'MUNITIONS' => $this->munitions,
			'RECHERCHE' => $this->recherche,
			'LVL1' => $this->lvl1,
			'LVL2' => $this->lvl2,
			'LVL3' => $this->lvl3,
			'LVL4' => $this->lvl4,
			'LVL5' => $this->lvl5 ));
					
	}//updateBDD
	
}//fin class Player


}//fin Try
catch (Exception $e)
{
	die('Erreur : ' . $e->getMessage());
}

?>
